home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / dev / misc / Progr_Langs_v6.lha / Progr_Langs / cpp_verification / t.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-19  |  295 b   |  22 lines

  1. #include <iostream.h>
  2.  
  3. // Template verification
  4.  
  5. template<class T> void swap(T &a, T &b)
  6. {
  7.   T c;
  8.   c = a;
  9.   a = b;
  10.   b = c;
  11. }
  12.  
  13. void main()
  14. {
  15.   int a, b;
  16.   a = 2;
  17.   b = 5;
  18.   cout << "before swap(): " << a << ":" << b << endl;
  19.   swap(a, b);
  20.   cout << "after swap(): " << a << ":" << b << endl;
  21. }
  22.